import React, { Component } from 'react';
import { Map } from 'immutable';

import Child from './Child';
import Demo from './Demo';

export default class App extends Component {
  state = {
    info: Map({
      name: 'zhangsan',
      select: 'aa',
      filter: Map({
        text: '',
        up: true,
        down: false,
      }),
    }),
  };

  componentDidMount() {
    console.log(this.state.info.get('filter'));
  }
  render() {
    return (
      <div>
        <h1>App</h1>
        <div>
          <button
            onClick={() => {
              this.setState({
                info: this.state.info.set('name', 'lisi-' + Math.random()),
              });
            }}>
            click
          </button>
        </div>
        <div>{this.state.info.get('name')}</div>
        <div>{this.state.info.get('select')}</div>
        <Child filter={this.state.info.get('filter')} />
        <Demo filter={this.state.info.get('filter')} />
      </div>
    );
  }
}
